/* eslint-disable */
// @ts-nocheck
import { Button } from '@/components/bs-ui/button'
import { Dialog, DialogTrigger } from '@/components/bs-ui/dialog'
import { Textarea } from '@/components/bs-ui/input'
import { useAssistantStore } from '@/store/assistantStore'
import { MixerHorizontalIcon } from '@radix-ui/react-icons'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import AutoPromptDialog from './AutoPromptDialog'

export default function Prompt() {
  const { t } = useTranslation()

  const [open, setOpen] = useState(false)

  const { assistantState, dispatchAssistant } = useAssistantStore()

  useEffect(() => {
    // 新建助手自动开启优化
    if (window.assistantCreate && assistantState.prompt) {
      setOpen(true)
      delete window.assistantCreate
    }
  }, [assistantState.prompt])

  return (
    <div className="h-full w-[50%] overflow-y-auto bg-[#fff] p-4 shadow-sm scrollbar-hide">
      <div className="flex-between-center">
        <span className="text-sm font-medium leading-none">{t('build.assistantPortrait')}</span>
        <Dialog open={open} onOpenChange={setOpen}>
          <DialogTrigger asChild>
            <Button variant="link" className="p-0">
              <MixerHorizontalIcon className="mr-1" />
              {t('build.automaticOptimization')}
            </Button>
          </DialogTrigger>
          {open && <AutoPromptDialog onOpenChange={setOpen}></AutoPromptDialog>}
        </Dialog>
      </div>
      <div className="h-[90%]">
        <Textarea
          className="h-full resize-none border-none bg-transparent text-sm text-muted-foreground scrollbar-hide focus-visible:ring-0"
          value={assistantState.prompt}
          placeholder={t('build.prompt')}
          onInput={e => dispatchAssistant('setPrompt', { prompt: e.target.value })}
        ></Textarea>
      </div>
    </div>
  )
}
